package com.zjsos;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.RandomUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.zaxxer.hikari.HikariConfig;
import com.zjsos.dao.BaseServiceImpl;
import com.zjsos.dao.IBaseService;
import com.zjsos.entity.casm.ZCasm;
import com.zjsos.entity.casx.ZCas;
import com.zjsos.entity.user.ZUser;
@RestController
@RequestMapping("/aa")
@SpringBootApplication(scanBasePackages = { "com.zjsos.**" }
, exclude= {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class}
)
public class Application {

	public static void main(String[] args) throws Exception {
		ApplicationContext ctx = SpringApplication.run(Application.class, args);
	}

	@Autowired
	private IBaseService baseServiceImpl;

//	@Autowired
//	@Qualifier("casDbServiceImpl")
//	private IBaseService casDbServiceImpl;
//	
//	@Autowired
//	@Qualifier("casmDbServiceImpl")
//	private IBaseService casmDbServiceImpl;

	@GetMapping("save")
	@Transactional(rollbackFor = Exception.class)
	public void save(HttpServletRequest request) throws Exception {
		
		ZUser u1 = new ZUser(RandomUtils.nextInt()+"");
		baseServiceImpl.save(u1);
		
//		ZCas u2 = new ZCas(RandomUtils.nextInt()+"");
//		casDbServiceImpl.save(u2);
//
//		ZCasm u3 = new ZCasm(RandomUtils.nextInt()+"");
//		casmDbServiceImpl.save(u3);
//		
		String a = request.getParameter("a");
		if(null!=a) {
			throw new Exception();
		}
	}
}
